const Router = require('koa-router')
const { verifyAuth } = require('../middleware/auth.middleware')
const { avatarHandler, pictureHandler, fileHandler } = require('../middleware/file.middleware')
const { saveAvatarInfo, saveFileInfo, returnFileInfo, otherFileInfo, setCodingType, otherFileInfoList } = require('../controller/file.controller')
const fileRouter = new Router({ prefix: '/upload' })
fileRouter.post('/avatar', verifyAuth, avatarHandler, saveAvatarInfo)
// fileRouter.post('/picture', verifyAuth, pictureHandler, savePictureInfo)
//图片上传
fileRouter.post('/picture', pictureHandler, returnFileInfo)
//其他文件上传
fileRouter.post('/file', fileHandler, saveFileInfo)
fileRouter.get('/file/:filename', otherFileInfo)
fileRouter.get('/list', otherFileInfoList)
module.exports = fileRouter